package com.java.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.java.dao.BookingMapper;
import com.java.model.AdvertisersAccount;
import com.java.model.Booking;
import com.java.model.Result;
import com.java.service.BookingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;


@Service
public class BookingServiceImpl implements BookingService {
    @Autowired
    private BookingMapper bookingMapper;

    @Override
    public void addOrder(Booking booking) {
        bookingMapper.addOrder(booking);
    }

    @Override
    public Result orderList(Booking booking) {
        PageHelper.startPage(booking.getPageNum(), booking.getPageSize()); // 提醒page在显示哪一页的数据和要显示多少条数据
        List<Booking> list = bookingMapper.orderList(booking);
        PageInfo<Booking> pageInfo = new PageInfo<>(list);

        return Result.success(pageInfo.getList(), pageInfo.getTotal());
    }

    @Override
    public Result orderList2(Booking booking) {
        PageHelper.startPage(booking.getPageNum(), booking.getPageSize()); // 提醒page在显示哪一页的数据和要显示多少条数据
        List<Booking> list = bookingMapper.orderList2(booking);
        PageInfo<Booking> pageInfo = new PageInfo<>(list);

        return Result.success(pageInfo.getList(), pageInfo.getTotal());
    }

    @Override
    public Result orderList3(Booking booking) {
        PageHelper.startPage(booking.getPageNum(), booking.getPageSize()); // 提醒page在显示哪一页的数据和要显示多少条数据
        List<Booking> list = bookingMapper.orderList3(booking);
        PageInfo<Booking> pageInfo = new PageInfo<>(list);

        return Result.success(pageInfo.getList(), pageInfo.getTotal());
    }

    @Override
    public void yes(Booking booking) {
        bookingMapper.no(booking);
    }

    @Override
    public void no(Booking booking) {
        bookingMapper.no(booking);
    }

    @Override
    public Result save(Booking booking) {
        return null;
    }

    @Override
    public Result modify(Booking booking) {
        return null;
    }

    @Override
    public Result remove(int[] ids) {
        return null;
    }

    @Override
    public Result list(Booking booking) {
        PageHelper.startPage(booking.getPageNum(), booking.getPageSize()); // 提醒page在显示哪一页的数据和要显示多少条数据
        List<Booking> list = bookingMapper.list(booking);
        PageInfo<Booking> pageInfo = new PageInfo<>(list);

        return Result.success(pageInfo.getList(), pageInfo.getTotal());
    }

    @Override
    public Result get(int id) {
        return null;
    }
}
